home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 24 / AMIGAplus Sonderheft 24 (2000)(Falke)(DE)[!].iso / PublicDomain / Anwendungen / MT-RechnungIII / Rexx / Import_MTRechnungII.rexx < prev    next >
OS/2 REXX Batch file  |  1998-11-01  |  13KB  |  471 lines

  1. /*
  2. ** Importieren der Daten von MT-RechnungII in MT-RechnungIII
  3. ** $VER: Import_MTRechnungII.rexx V1.02 (01.11.98)
  4. */
  5.  
  6. PARSE ARG ARexxPort;
  7.  
  8. ADDRESS VALUE ARexxPort;
  9. OPTIONS RESULTS;
  10.  
  11. LF                    = '0a'x;                            /* Zeilenvorschub                */
  12.  
  13. RC = 0;
  14.  
  15. /* Oberfläche sperren */
  16. LOCKGUI;
  17.  
  18. /* Prüfen, ob nicht bereits Daten vorhanden sind (darf nicht sein) */
  19. NUMBER_ADDRESS;
  20. AnzahlAdressen    = MTR_RESULT;
  21. NUMBER_ARTICLE;
  22. AnzahlArtikel    = MTR_RESULT;
  23. NUMBER_OUTBILL;
  24. AnzahlRechnung    = MTR_RESULT;
  25.  
  26. IF (AnzahlAdressen + AnzahlArtikel + AnzahlRechnung) > 0 THEN
  27.     DO;
  28.         ES_TITLE                = "Achtung!!!!";
  29.         ES_TEXTFORMAT        = "Die Daten können nur importiert werden," || LF || "wenn noch keine Eingaben erfolgten.";
  30.         ES_GADGETFORMAT    = "Abbrechen";
  31.         EASY_REQUEST;
  32.         RC = 1;
  33.     END;
  34.  
  35. /* Einstellungsdatei auswählen */
  36. IF RC = 0 THEN
  37.     DO;
  38.         ASLFR_TITLETEXT        = "Wählen Sie die Einstellungsdatei";
  39.         ASLFR_INITIALDRAWER    = "ram:";
  40.         ASLFR_INITIALPATTERN    = "#?.dat";
  41.         ASLFR_INITIALFILE        = "Prefs.dat";
  42.         ASL_FILE_REQUEST;
  43.         IF MTR_RESULT = "" THEN
  44.             RC = 1;
  45.         ELSE
  46.             DO;
  47.                 PrefsDatei = MTR_RESULT;
  48.                 j = 0;
  49.                 i = INDEX( PrefsDatei, "/");
  50.                 DO WHILE( i > 0 );
  51.                     j = i;
  52.                     i = INDEX( PrefsDatei, "/", i+1);
  53.                 END;
  54.  
  55.                 IF J = 0 THEN
  56.                     J = INDEX( PrefsDatei, ":" );
  57.  
  58.                 Vorgabeverzeichnis = SUBSTR( PrefsDatei, 1, J );
  59.             END;
  60.     END;
  61.  
  62. /* Artikeldatei auswählen */
  63. IF RC = 0 THEN
  64.     DO;
  65.         ASLFR_TITLETEXT        = "Wählen Sie die Artikeldatei";
  66.         ASLFR_INITIALDRAWER    = Vorgabeverzeichnis;
  67.         ASLFR_INITIALPATTERN    = "#?.dat";
  68.         ASLFR_INITIALFILE        = "Artikel.dat";
  69.         ASL_FILE_REQUEST;
  70.         IF MTR_RESULT = "" THEN
  71.             RC = 1;
  72.         ELSE
  73.             DO;
  74.                 ArtikelDatei = MTR_RESULT;
  75.             END;
  76.     END;
  77.  
  78. /* Kundendatei auswählen */
  79. IF RC = 0 THEN
  80.     DO;
  81.         ASLFR_TITLETEXT        = "Wählen Sie die Kundendatei";
  82.         ASLFR_INITIALDRAWER    = Vorgabeverzeichnis;
  83.         ASLFR_INITIALPATTERN    = "#?.dat";
  84.         ASLFR_INITIALFILE        = "Kunden.dat";
  85.         ASL_FILE_REQUEST;
  86.         IF MTR_RESULT = "" THEN
  87.             RC = 1;
  88.         ELSE
  89.             DO;
  90.                 KundenDatei = MTR_RESULT;
  91.             END;
  92.     END;
  93.  
  94. /* Rechnungsdatei auswählen */
  95. IF RC = 0 THEN
  96.     DO;
  97.         ASLFR_TITLETEXT        = "Wählen Sie die Rechnungsdatei";
  98.         ASLFR_INITIALDRAWER    = Vorgabeverzeichnis;
  99.         ASLFR_INITIALPATTERN    = "#?.dat";
  100.         ASLFR_INITIALFILE        = "Rechnung.dat";
  101.         ASL_FILE_REQUEST;
  102.         IF MTR_RESULT = "" THEN
  103.             RC = 1;
  104.         ELSE
  105.             DO;
  106.                 RechnungsDatei = MTR_RESULT;
  107.             END;
  108.     END;
  109.  
  110. /* Noch kein Fehler Aufgetreten? */
  111. IF RC = 0 THEN
  112.     DO;
  113.         /* Länder einlesen */
  114.         NUMBER_COUNTRY;
  115.         AnzLaender = MTR_RESULT;
  116.         DO i = 1 to AnzLaender;
  117.             GET_COUNTRY i;
  118.             LandesName.i = COUNTRY.NAME;
  119.         END;
  120.  
  121.         /* Einstellungen anpassen */
  122.         GET_PREFS;
  123.  
  124.         IF OPEN(P_dat,PrefsDatei,'read') THEN
  125.             DO;
  126.                 PREFS.VALUEPERCENT.0    = READLN(P_dat);
  127.                 PREFS.VALUEPERCENT.1    = READLN(P_dat);
  128.                 CLOSE(P_dat);
  129.             END;
  130.         ELSE
  131.             DO;
  132.                 PREFS.VALUEPERCENT.0    = 16;
  133.                 PREFS.VALUEPERCENT.1    = 7;
  134.             END;
  135.         PREFS.CURRENCY_USED            = 1;
  136.         IF PREFS.ADD_RED_USED        = 0 THEN
  137.             DO;
  138.                 PREFS.ADD_RED_USED    = 1;
  139.                 PREFS.ADD_RED_TEXT.0    = "Nachlass %";
  140.                 PREFS.ADD_RED_TYPE.0    = 5;
  141.             END;
  142.         SET_PREFS;
  143.  
  144.         /* Artikel einlesen */
  145.         IF OPEN(A_dat,ArtikelDatei,'read') THEN
  146.             DO;
  147.                 DO forever;
  148.                     AR_ArtBez        = READLN(A_dat);
  149.                     IF EOF(A_dat) THEN LEAVE;
  150.                     AR_ArtPreis        = READLN(A_dat);
  151.                     AR_ArtBuch        = READLN(A_dat);
  152.                     AR_ArtMWST        = READLN(A_dat);
  153.  
  154.                     IF AR_ArtMWSt    < '1' | AR_ArtMWSt > '9' THEN
  155.                         AR_ArtMWSt    = 1;
  156.  
  157.                     NEW_ARTICLE;
  158.                     Artikelnummer  = MTR_RESULT;
  159.                     ARTICLE.DESCRIPTION                = AR_ArtBez;
  160.                     ARTICLE.BOOK_KEEPING_ACCOUNT    = AR_ArtBuch;
  161.                     ARTICLE.VALUE_USED                = AR_ArtMWSt - 1;
  162.                     ARTICLE.PRICE.0.1                    = AR_ArtPreis;
  163.                     ARTICLE.CURRENCY_USED            = 1;
  164.                     SET_ARTICLE Artikelnummer;
  165.                 END;
  166.                 CLOSE(A_dat);
  167.             END;
  168.  
  169.         /* Adressen einlesen */
  170.         IF OPEN(K_dat,KundenDatei,'read') THEN
  171.             DO;
  172.                 DO forever;
  173.                     VorName        = READLN(K_dat);
  174.                     IF EOF(K_dat) THEN LEAVE;
  175.                     NachName        = READLN(K_dat);
  176.                     Strasse        = READLN(K_dat);
  177.                     PLZ            = READLN(K_dat);
  178.                     ORT            = READLN(K_dat);
  179.                     Land            = READLN(K_dat);
  180.                     GebTag        = READLN(K_dat);
  181.                     Rabatt        = READLN(K_dat);
  182.                     Tel            = READLN(K_dat);
  183.                     Fax            = READLN(K_dat);
  184.                     Dfue            = READLN(K_dat);
  185.                     EMail1        = READLN(K_dat);
  186.                     EMail2        = READLN(K_dat);
  187.                     EMail3        = READLN(K_dat);
  188.                     Anrede        = READLN(K_dat);
  189.                     BAnr            = READLN(K_dat);
  190.                     Komm            = READLN(K_dat);
  191.                     BLZ            = READLN(K_dat);
  192.                     BankBez        = READLN(K_dat);
  193.                     BankKurz        = READLN(K_dat);
  194.                     Konto            = READLN(K_dat);
  195.  
  196.                     NEW_ADDRESS;
  197.                     Adressnummer    = MTR_RESULT;
  198.                     SELECT;
  199.                         WHEN Anrede = "Fräulein" THEN
  200.                             DO;
  201.                                 ADDRESS.SALUTATION = 1;
  202.                             END;
  203.                         WHEN Anrede = "Frau" THEN
  204.                             DO;
  205.                                 ADDRESS.SALUTATION = 2;
  206.                             END;
  207.                         WHEN Anrede = "Herr" | Anrede = "Herrn" THEN
  208.                             DO;
  209.                                 ADDRESS.SALUTATION = 3;
  210.                             END;
  211.                         WHEN Anrede = "Familie" THEN
  212.                             DO;
  213.                                 ADDRESS.SALUTATION = 4;
  214.                             END;
  215.                         OTHERWISE
  216.                             DO;
  217.                                 ADDRESS.SALUTATION = 0;
  218.                             END;
  219.                     END;
  220.                     ADDRESS.SURNAME        = NachName;
  221.                     ADDRESS.PRENAME        = VorName;
  222.                     ADDRESS.STREET            = Strasse;
  223.                     ADDRESS.ZIP                = PLZ;
  224.                     ADDRESS.CITY            = ORT;
  225.  
  226.                     SELECT;
  227.                         WHEN Land    = "Germany" | Land = "" THEN
  228.                             Land        = "Deutschland";
  229.                         WHEN Land    = "Austria" THEN
  230.                             Land        = "Österreich";
  231.                         WHEN Land    = "Swiss" THEN
  232.                             Land        = "Schweiz";
  233.                         OTHERWISE
  234.                             NOP;
  235.                     END;
  236.                     j = 0;
  237.                     DO i = 1 to AnzLaender WHILE(j = 0);
  238.                         IF Land        = LandesName.i THEN
  239.                         j = i;
  240.                     END;
  241.                     IF j = 0 THEN
  242.                         DO;
  243.                             NEW_COUNTRY;
  244.                             AnzLaender = MTR_RESULT;
  245.                             i = MTR_RESULT;
  246.                             COUNTRY.NAME    = Land;
  247.                             LandesName.i    = COUNTRY.NAME;
  248.                             SELECT;
  249.                                 WHEN COUNTRY.NAME = "Deutschland" THEN
  250.                                     DO;
  251.                                         COUNTRY.SYMBOL                    = "D-";
  252.                                         COUNTRY.PHONE_HOME            = "0";
  253.                                         COUNTRY.PHONE_FOREIGN        = "00";
  254.                                         COUNTRY.PHONE_FROMFOREIGN    = "49";
  255.                                         COUNTRY.STATE.0                = "Baden-Würtemberg"
  256.                                         COUNTRY.STATE.1                = "Bayern";
  257.                                         COUNTRY.STATE.2                = "Berlin";
  258.                                         COUNTRY.STATE.3                = "Brandenburg";
  259.                                         COUNTRY.STATE.4                = "Bremen";
  260.                                         COUNTRY.STATE.5                = "Hamburg";
  261.                                         COUNTRY.STATE.6                = "Hessen";
  262.                                         COUNTRY.STATE.7                = "Mecklenburg-Vorpommern";
  263.                                         COUNTRY.STATE.8                = "Niedersachsen";
  264.                                         COUNTRY.STATE.9                = "Nordrhein-Westfalen";
  265.                                         COUNTRY.STATE.10                = "Rheinland-Pfalz";
  266.                                         COUNTRY.STATE.11                = "Saarland";
  267.                                         COUNTRY.STATE.12                = "Sachsen";
  268.                                         COUNTRY.STATE.13                = "Sachsen-Anhalt";
  269.                                         COUNTRY.STATE.14                = "Schleswig-Holstein";
  270.                                         COUNTRY.STATE.15                = "Thüringen";
  271.                                     END;
  272.                                 WHEN COUNTRY.NAME = "Österreich" THEN
  273.                                     DO;
  274.                                         COUNTRY.SYMBOL                    = "A-";
  275.                                         COUNTRY.PHONE_HOME            = "0";
  276.                                         COUNTRY.PHONE_FOREIGN        = "00";
  277.                                         COUNTRY.PHONE_FROMFOREIGN    = "43";
  278.                                         COUNTRY.STATE.0                = "Burgenland"
  279.                                         COUNTRY.STATE.1                = "Kärnten";
  280.                                         COUNTRY.STATE.2                = "Niederösterreich";
  281.                                         COUNTRY.STATE.3                = "Oberösterreich";
  282.                                         COUNTRY.STATE.4                = "Salzburg";
  283.                                         COUNTRY.STATE.5                = "Steiermark";
  284.                                         COUNTRY.STATE.6                = "Tirol";
  285.                                         COUNTRY.STATE.7                = "Vorarlberg";
  286.                                         COUNTRY.STATE.8                = "Wien";
  287.                                     END;
  288.                                 WHEN COUNTRY.NAME = "Schweiz" THEN
  289.                                     DO;
  290.                                         COUNTRY.SYMBOL                    = "CH-";
  291.                                         COUNTRY.PHONE_HOME            = "0";
  292.                                         COUNTRY.PHONE_FOREIGN        = "00";
  293.                                         COUNTRY.PHONE_FROMFOREIGN    = "41";
  294.                                         COUNTRY.STATE.0                = "Aargau"
  295.                                         COUNTRY.STATE.1                = "Appenzell Außer-Rhoden";
  296.                                         COUNTRY.STATE.2                = "Appenzell Inner-Rhoden";
  297.                                         COUNTRY.STATE.3                = "Basel-Land";
  298.                                         COUNTRY.STATE.4                = "Basel-Stadt";
  299.                                         COUNTRY.STATE.5                = "Bern";
  300.                                         COUNTRY.STATE.6                = "Freiburg";
  301.                                         COUNTRY.STATE.7                = "Genf";
  302.                                         COUNTRY.STATE.8                = "Glarus";
  303.                                         COUNTRY.STATE.9                = "Graubünden";
  304.                                         COUNTRY.STATE.10                = "Luzern";
  305.                                         COUNTRY.STATE.11                = "Neuenburg";
  306.                                         COUNTRY.STATE.12                = "Sankt Gallen";
  307.                                         COUNTRY.STATE.13                = "Schaffhausen";
  308.                                         COUNTRY.STATE.14                = "Schwyz";
  309.                                         COUNTRY.STATE.15                = "Solothurn";
  310.                                         CO